package it.unibo.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Information 
{
	private String name;
	private Map<String, String> attributes;
	private List<Information> children;
	
	public Information(String name)
	{
		this.name = name;
		attributes = new HashMap<String, String>();
		children = new ArrayList<Information>();
	}
	
	public String getName()
	{
		return name;
	}
	
	public void addChildInformation(Information info)
	{
		children.add(info);
	}
	
	public void addChildInformations(List<Information> infos)
	{
		children.addAll(infos);
	}
	
	public void removeChildInformation(Information info)
	{
		children.remove(info);
	}
	
	public List<Information> getChildrenInformations()
	{
		return children;
	}
	
	public void addAttribute(String name, String value)
	{
		attributes.put(name, value);
	}
	
	public void removeAttribute(String name)
	{
		attributes.remove(name);
	}
	
	public void setAttribute(String name, String value)
	{
		if(attributes.containsKey(name))
			attributes.put(name, value);
	}
	
	public Map<String,String> getAttributes()
	{
		return attributes;
	}
}
